package com.trace.pplos.parse.dao.dataobject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class ClwzInfo {
    private static final Logger logger = LoggerFactory.getLogger(ClwzInfo.class);

    private Integer id;

    private String carNo;

    private String lng;

    private String lat;

    private String address;

    private String detailAddress;

    private String content;

    private String des;

    private String carFrontPhotoPath;

    private String carBehindPhotoPath;

    private String carSidePhotoPath;

    private String locMapSnapPath;

    private String otherPhotoPath;

    private String synced;

    private String lngGps;

    private String latGps;

    private String cjdw;

    private String filepath;

    private Date gmtCreate;

    private String gmtCreateUser;

    private Date gmtModified;

    private String gmtModifiedUser;

    private Integer status;

    public ClwzInfo(Integer id, String carNo, String lng, String lat, String address, String detailAddress, String content, String des, String carFrontPhotoPath, String carBehindPhotoPath, String carSidePhotoPath, String locMapSnapPath, String otherPhotoPath, String synced, String lngGps, String latGps, String cjdw, String filepath, Date gmtCreate, String gmtCreateUser, Date gmtModified, String gmtModifiedUser, Integer status) {
        this.id = id;
        this.carNo = carNo;
        this.lng = lng;
        this.lat = lat;
        this.address = address;
        this.detailAddress = detailAddress;
        this.content = content;
        this.des = des;
        this.carFrontPhotoPath = carFrontPhotoPath;
        this.carBehindPhotoPath = carBehindPhotoPath;
        this.carSidePhotoPath = carSidePhotoPath;
        this.locMapSnapPath = locMapSnapPath;
        this.otherPhotoPath = otherPhotoPath;
        this.synced = synced;
        this.lngGps = lngGps;
        this.latGps = latGps;
        this.cjdw = cjdw;
        this.filepath = filepath;
        this.gmtCreate = gmtCreate;
        this.gmtCreateUser = gmtCreateUser;
        this.gmtModified = gmtModified;
        this.gmtModifiedUser = gmtModifiedUser;
        this.status = status;
    }

    public ClwzInfo() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCarNo() {
        return carNo;
    }

    public void setCarNo(String carNo) {
        this.carNo = carNo == null ? null : carNo.trim();
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng == null ? null : lng.trim();
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat == null ? null : lat.trim();
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address == null ? null : address.trim();
    }

    public String getDetailAddress() {
        return detailAddress;
    }

    public void setDetailAddress(String detailAddress) {
        this.detailAddress = detailAddress == null ? null : detailAddress.trim();
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content == null ? null : content.trim();
    }

    public String getDes() {
        return des;
    }

    public void setDes(String des) {
        this.des = des == null ? null : des.trim();
    }

    public String getCarFrontPhotoPath() {
        return carFrontPhotoPath;
    }

    public void setCarFrontPhotoPath(String carFrontPhotoPath) {
        this.carFrontPhotoPath = carFrontPhotoPath == null ? null : carFrontPhotoPath.trim();
    }

    public String getCarBehindPhotoPath() {
        return carBehindPhotoPath;
    }

    public void setCarBehindPhotoPath(String carBehindPhotoPath) {
        this.carBehindPhotoPath = carBehindPhotoPath == null ? null : carBehindPhotoPath.trim();
    }

    public String getCarSidePhotoPath() {
        return carSidePhotoPath;
    }

    public void setCarSidePhotoPath(String carSidePhotoPath) {
        this.carSidePhotoPath = carSidePhotoPath == null ? null : carSidePhotoPath.trim();
    }

    public String getLocMapSnapPath() {
        return locMapSnapPath;
    }

    public void setLocMapSnapPath(String locMapSnapPath) {
        this.locMapSnapPath = locMapSnapPath == null ? null : locMapSnapPath.trim();
    }

    public String getOtherPhotoPath() {
        return otherPhotoPath;
    }

    public void setOtherPhotoPath(String otherPhotoPath) {
        this.otherPhotoPath = otherPhotoPath == null ? null : otherPhotoPath.trim();
    }

    public String getSynced() {
        return synced;
    }

    public void setSynced(String synced) {
        this.synced = synced == null ? null : synced.trim();
    }

    public String getLngGps() {
        return lngGps;
    }

    public void setLngGps(String lngGps) {
        this.lngGps = lngGps == null ? null : lngGps.trim();
    }

    public String getLatGps() {
        return latGps;
    }

    public void setLatGps(String latGps) {
        this.latGps = latGps == null ? null : latGps.trim();
    }

    public String getCjdw() {
        return cjdw;
    }

    public void setCjdw(String cjdw) {
        this.cjdw = cjdw == null ? null : cjdw.trim();
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath(String filepath) {
        this.filepath = filepath == null ? null : filepath.trim();
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtCreateUser() {
        return gmtCreateUser;
    }

    public void setGmtCreateUser(String gmtCreateUser) {
        this.gmtCreateUser = gmtCreateUser == null ? null : gmtCreateUser.trim();
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public String getGmtModifiedUser() {
        return gmtModifiedUser;
    }

    public void setGmtModifiedUser(String gmtModifiedUser) {
        this.gmtModifiedUser = gmtModifiedUser == null ? null : gmtModifiedUser.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public static ClwzInfo toBean(String object){
        try{
            ClwzInfo info = new ClwzInfo();
            JSONObject record = JSON.parseObject(object);
            info.setSynced("0");
            info.setCarNo(record.getString("cphm"));
            info.setLng(record.getString("longitude"));
            info.setLat(record.getString("latitude"));
            info.setContent(record.getString("wzyj"));
            info.setDes(record.getString("des"));
            info.setAddress(record.getString("address"));
            info.setDetailAddress(record.getString("xxdz"));

            info.setGmtCreate(record.getDate("createdAt"));
            info.setGmtCreateUser(record.getString("createdBy"));
            //info.setGmtModified(record.getDate("modifiedAt"));
            info.setGmtModified(new Date());
            info.setGmtModifiedUser(record.getString("modifiedBy"));

            //现场方位图
            String filePaths = "";
            JSONArray list = record.getJSONArray("xcfwPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setLocMapSnapPath(filePaths);

            //车辆前面照
            filePaths = "";
            list = record.getJSONArray("clqmPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setCarFrontPhotoPath(filePaths);

            //车辆后面照
            filePaths = "";
            list = record.getJSONArray("clhmPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setCarBehindPhotoPath(filePaths);

            //车辆测面照
            filePaths = "";
            list = record.getJSONArray("clcmPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setCarSidePhotoPath(filePaths);
            return info;
        }catch (Exception e){
            logger.error(e.getMessage(), e);
        }
        return null;
    }
}